﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Xml;

namespace cityinfo
{
    public class CityList
    {
        XmlNode m_xml;
        // city sets
        private List<City> m_us;
        private List<City> m_international;
        private List<City> m_extra;

        public CityList()
        {
            init();
        }
        public CityList(XmlNode xml)
        {
            init();
            m_xml = xml;
            LoadXml(m_xml);
        }
        // init
        private void init()
        {
            m_xml = null;
            m_us = new List<City>();
            m_international = new List<City>();
            m_extra = new List<City>();
        }

        public bool LoadXml(XmlNode xml)
        {
            for (int i = 0; i < xml.ChildNodes.Count; i++)
            {
                City city = new City(xml.ChildNodes[i]);
                if (city.IsUSCity())
                    m_us.Add(city);
                else
                    m_international.Add(city);
            }
            return m_us.Count + m_international.Count > 0;
        }

        // access
        public List<City> USCities
        {
            get { return m_us; }
            //set { m_us = value; }
        }
        public List<City> InternationalCities
        {
            get { return m_international; }
            //set { m_international = value; }
        }
        public List<City> ExtraCities
        {
            get { return m_extra; }
            //set { m_extra = value; }
        }

    }
}
